package com.aifast.common.util;


import cn.hutool.core.lang.Console;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;

/**
 * spring提供的aes加密工具
 */
public class AESUtil {

    /**自定义秘钥*/
    private final static String secretKey = "20200509fujian34MDSA2154JDSACPCJFHA9353MCSNDAMAISINJUARO0523NM=";
    /**加密盐*/
    private final static String salt = "0123456789ABCDEF";

    /**客户系统电话用*/
    private static final byte[] key = "8mf6dsjidxk23jar".getBytes();

    private static SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);


    /**
     * 20211210 新增对称加密方法
     * @param str
     * @return
     */
    public static String encryptHex(String str){
        String encryptHex = aes.encryptHex(str);
        return encryptHex;
    }

    /**
     * 20211210 新增对称解密方法
     * @param str
     * @return
     */
    public static String decryptStr(String str){
        String decryptStr = aes.decryptStr(str, CharsetUtil.CHARSET_UTF_8);
        return decryptStr;
    }

    public static void main(String[] args) {
        Console.log(encryptHex("16689674087"));
    }

}
